package top.zuli.package01.class15;

import org.junit.Test;

public class Demo1 {
    @Test
    public void StringMethodTest1(){
        String str = "abc";
        String str2 = new String("abc");
        String str3 = "ABC";
        //比较字符串内容是否相等
        System.out.println(str.equals(str2));
        //忽略大小写比较字符串内容是否相等
        System.out.println(str.equalsIgnoreCase(str3));
        //比较字母的字典顺序
        System.out.println("a".compareTo("b"));
        //判断字符串是否以"a"开头
        System.out.println(str.startsWith("a"));
        //测试此字符串从指定索引开始的子字符串是否以指定前缀开始
        System.out.println(str.startsWith("b",1));
        //判断字符串是否以bc结尾
        System.out.println(str.endsWith("bc"));
        //判断字符串是否包含"b"
        System.out.println(str.contains("b"));
    }
}

/*
public class Demo1 {
    @Test
    public void StringMethodTest1() {
        String str = "abc";
        String str1 = new String("abc");
        String str2 = "ABC";
        System.out.println(str.equals(str1));
        System.out.println(str.equalsIgnoreCase(str2));
        System.out.println("a".compareTo("b"));
        System.out.println("a".compareToIgnoreCase("A"));
        System.out.println(str.startsWith("a"));
        System.out.println(str.startsWith("b",1));
        System.out.println(str.endsWith("bc"));
        System.out.println(str.contains("b"));
    }
}
*/

/*
public class Demo1 {
    @Test
    public void StringMethodTest1() {
        String str = "abc";
        String str1 = new String("abc");
        String str2 = "ABCDEFG";
        System.out.println(str.equals(str1));
        System.out.println(str.equalsIgnoreCase(str2));
        System.out.println(str.compareTo(str1));
        System.out.println("abcd".compareTo("abcd"));
        System.out.println("anc".equals("abc"));
        System.out.println("abcd".startsWith("a"));
        System.out.println("abcdef".startsWith("c",2));
        System.out.println("abcdef".startsWith("c",1));
        System.out.println("abcde".endsWith("d"));
        System.out.println("abcde".endsWith("de"));
        System.out.println("abcde".endsWith("e"));
        System.out.println("abcd".contains("e"));
        System.out.println("abcd".contains("c"));
    }
}
*/

